package com.qiaoba.file.minio.config;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * Minio 配置
 *
 * @author ailanyin
 * @date 2023-09-26 09:40:57
 */
@Configuration
@ComponentScan("com.qiaoba.file.minio")
public class MinioConfig {

    public static String endpoint;

    @Value("${minio.endpoint}")
    private void setEndpoint(String url) {
        endpoint = url;
    }

    @Value("${minio.accessKey}")
    private String accessKey;

    @Value("${minio.secretKey}")
    private String secretKey;

    @Bean
    public MinioClient minioClient() {
        //创建一个MinIO的Java客户端
        return MinioClient.builder()
                .endpoint(endpoint)
                .credentials(accessKey, secretKey)
                .build();
    }
}
